<%@ page contentType="text/html; charset=UTF-8" %>
<%@ taglib uri="http://java.sun.com/jstl/core"
         prefix="c" %>
<%@ page
	import="org.springframework.security.web.authentication.UsernamePasswordAuthenticationFilter"%>
<%@ page import="org.springframework.security.core.AuthenticationException"%>
<html>
<head>
<title>Login</title>
<link href="login-box.css" rel="stylesheet" type="text/css" />
</head>
<body>
<!-- 	<h1>Login</h1> -->
	<%-- <c:if test="${not empty param.login_error}">
		<font color="red"> Your login attempt was not successful, try
			again.<br />
		<br /> Reason: <c:out
				value="${SPRING_SECURITY_LAST_EXCEPTION.message}" />.
		</font>
	</c:if> --%>
	
<%-- 	<%if (request.getParameter("login_error")!=null){%>	
		<font color="red"> Your login attempt was not successful, try
			again.<br />
		<br /> Reason: <% Exception exception = (Exception)session.getAttribute(AuthenticationProcessingFilter.SPRING_SECURITY_LAST_EXCEPTION_KEY); 
		out.print(exception.getMessage());
		%>
				
		</font>
	<%}%>
	<form name="f" action="<c:url value='j_spring_security_check'/>"
		method="POST">
		<table>
			<tr>
				<td>User:</td>
				
				<td><input type='text' name='j_username'
					value='<c:if test="${not empty param.login_error}"><c:out value="${SPRING_SECURITY_LAST_USERNAME}"/></c:if>' /></td>
						<td><input type='text' name='j_username'
					value='<%if(request.getParameter("login_error")!=null){
					String usrname = (String)session.getAttribute(AuthenticationProcessingFilter.SPRING_SECURITY_LAST_USERNAME_KEY);
					out.print(usrname);
				}%>' /></td>
					
			</tr>
			<tr>
				<td>Password:</td>
				<td><input type='password' name='j_password'></td>
			</tr>
			<tr>
				<td><input type="checkbox" name="_spring_security_remember_me"></td>
				<td>Don't ask for my password for two weeks</td>
			</tr>
			<tr>
				<td colspan='2'><input name="submit" type="submit" value="Login"></td>
			</tr>
			<tr>
				<td colspan='2'><input name="reset" type="reset"></td>
			</tr>
		</table>
	</form>
 --%>


		<div style="padding: 100px 0 0 250px;">
	<form name="f" action="<c:url value='j_spring_security_check'/>"
		method="POST">	
			<div id="login-box">

				<H2>Login</H2>
				<%
					if (request.getParameter("login_error") != null) {
				%>
				<font color="#EBEBEB"> Your login attempt was not successful, try
					again.<br /> <br /> Reason: <%
 	Exception exception = (Exception) session
 				.getAttribute(UsernamePasswordAuthenticationFilter.SPRING_SECURITY_LAST_EXCEPTION_KEY);
 		out.print(exception.getMessage());
 %>

				</font>
				<%
					}
				%>
				<br /> <br />
				<div id="login-box-name" style="margin-top: 20px;">User:</div>
				<div id="login-box-field" style="margin-top: 20px;">
					<input class="form-login" title="Username"
						name="j_username"
						value="<%if (request.getParameter("login_error") != null) {
				String usrname = (String) session
						.getAttribute(UsernamePasswordAuthenticationFilter.SPRING_SECURITY_LAST_USERNAME_KEY);
				out.print((usrname != null)?usrname:"");
				
			}%>"
						size="30" maxlength="2048" />
				</div>
				<div id="login-box-name">Password:</div>
				<div id="login-box-field">
					<input type="password" name="j_password"
						class="form-login" title="Password" value="" size="30"
						maxlength="2048" />
				</div>
				<br /> <span class="login-box-options"><input
					type="checkbox" name="_spring_security_remember_me" value="1">
					Remember Me <a href="#" style="margin-left: 30px;">Forgot
						password?</a></span> <br /> <br /><input type="image"
					src="images/login-btn.png" width="103" height="42"
					style="margin-left: 90px;" value="Submit" alt="Submit"/>

			</div>
	</form>
		</div>


</body>
</html>